namespace java com.ebspp.thrift

struct Identity
{
	1:string key
}

struct DataMsg
{
	1:string key,
	2:string ts,
	3:binary value,
}

//to add a new type, you have to change two parts in the code
//1. ClientResManager, the getResouce() function should support the new type
//2. ResourceManager, the resource initiation part
enum ResourceType
{
	CPU = 1,
	NETWORK = 2,
	STORAGE = 3,
	TXN_STORAGE = 4,
	MEMORY = 5
}

enum WatchType
{
	STREAM = 1,
	SYNC = 2,
	ASYNC = 3
}



//if the client wants more resource, provision value should be positive
//if the client wants to release resource, provision value should be negative
service MsgTransfer
{
	map<ResourceType, i32> quest(),
	bool watch(1:ResourceType type, 2:Identity wID, 4:string IP),
	bool deWatch(1:ResourceType type, 2:Identity wID, 4:string IP),
}

service Watcher
{
	oneway void notify(1:list<DataMsg> data, 2:ResourceType type, 3:Identity wID),
}

service DataWrite
{
	bool provision(1:map<ResourceType, i32> resource, 2:Identity id),
	list<DataMsg> writeEBSPP(1:list<DataMsg> data, 2:ResourceType type, 3:Identity id),
}

service DataRead
{
	//it will return a string, either ip of itself or another candidate for the read
	string provision(1:map<ResourceType, i32> resource, 2:Identity id),
	list<DataMsg> readEBSPP(1:list<DataMsg> data, 2:ResourceType type, 3:Identity id)
}

service GarbageCollect
{
	list<DataMsg> garbageCollect(1:list<DataMsg> keys, 2:ResourceType type, 3:Identity id)
}

